import { defHttp } from '@/utils/http/axios';
import { ErrorMessageMode } from '#/axios';

enum Api {
  GetMenuList = '/getMenus',
  GetAllMenu = '/getAllMenus',
  UpdateMenu = '/updateMenu',
  AddMenu = '/addMenu',
  DeleteMenu = '/deleteMenu/',
  getRoleAllMenu = '/getRoleAllMenu',
  //获取机构所有菜单列表，用于机构管理分配机构权限
  getOrgAllMenu = '/getOrgAllMenu',
}

/**
 * @description: Get user menu based on id
 */
export const getRoleAllMenu = () => {
  return defHttp.get<any>({ url: Api.getRoleAllMenu });
};
export const getOrgAllMenu = () => {
  return defHttp.get<any>({ url: Api.getOrgAllMenu });
};
export const getMenuList = () => {
  return defHttp.get<any>({ url: Api.GetMenuList });
};
export const GetAllMenu = (params) => {
  return defHttp.get<any>({ params,url: Api.GetAllMenu, });
};
export const UpdateMenu = (params, mode: ErrorMessageMode = 'message') => {
  return defHttp.put<any>({ params,url: Api.UpdateMenu },
    {
      errorMessageMode: mode,
    },);
};
export const AddMenu = (params, mode: ErrorMessageMode = 'message') => {
  return defHttp.post<any>({ params,url: Api.AddMenu },
    {
      errorMessageMode: mode,
    },);
};
export const DeleteMenu = (params, mode: ErrorMessageMode = 'message') => {
  return defHttp.delete<any>({url: Api.DeleteMenu+params },
    {
      errorMessageMode: mode,
    },);
};
